<template>
  <div class="rightContent">
    <label class="flex-start">
      <div class="part flex-start">
        <span>会议名称</span>
        <input type="text" placeholder="请输入" v-model="searchForm.cf_name" />
      </div>
      <div class="part">
        <span>会议号</span>
        <input type="text" placeholder="请输入" v-model="searchForm.cf_code" />
      </div>
      <div class="part">
        <span>会议时间</span>
        <el-date-picker
          v-model="searchForm.start_time"
          type="date"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="开始时间">
        </el-date-picker>
      </div>
      <span class="btn-blue search" @click="getFileList">查询</span>
      <span class="btn-white2 reset" @click="reset">重置</span>
    </label>
    <table cellspacing="0">
      <thead>
        <th>会议名称</th>
        <th>会议号</th>
        <th>主持人</th>
        <th>开始时间</th>
        <th>会议纪要</th>
        <th>操作</th>
      </thead>
      <tbody v-if="cfList.length">
        <tr v-for="item in cfList" :key="item.cf_id">
          <td>
            {{ item.cf_name }}
          </td>
          <td>{{ item.cf_code }}</td>
          <td>{{ item.cf_host}}</td>
          <td>{{ item.cf_start_time}}</td>
          <td>{{ "无" }}</td>
          <td>
            <span class="view cp" @click="viewDesc(item)">查看详情</span>
          </td>
        </tr>
      </tbody>
    </table>
    <el-pagination
      v-if="total"
      @current-change="handleCurrentChange"
      :current-page="searchForm.page"
      :page-size="searchForm.page_size"
      layout="total, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    <empty-box v-else></empty-box>
    <cf-drawer :cf_id="selectCfId" :type="'history'" :title="drawerTitle" :ifShow="showCfDrawer" @closeDrawer="closeDrawer"></cf-drawer>
  </div>
</template>

<script>
import cfDrawer from '../cfDrawer'
import emptyBox from '../empty'
export default {
  name: 'rightContent',
  components: {
    cfDrawer, emptyBox
  },
  data () {
    return {
      selectCfId: 0,
      searchForm: {
        cf_code: '',
        cf_name: '',
        // end_time: '',
        page: 1,
        page_size: 12,
        start_time: null
      },
      drawerTitle: '', // 会议详情 弹框名称
      showCfDrawer: false
    }
  },
  computed: {
    // 会议列表
    cfList () {
      return this.$store.state.conference.historyCfDate.historyCfList
    },
    // 文件总数
    total () {
      return this.$store.state.conference.historyCfDate.total
    }
  },
  methods: {
    // 获取文件列表
    getFileList () {
      const timeZone = new Date().getTimezoneOffset() / 60
      const params = {
        ...this.searchForm
      }
      if (params.start_time) params.time_zone = timeZone
      this.$store.dispatch('conference/getHistoryCfList', params)
    },
    // 重置
    reset () {
      this.searchForm = {
        cf_code: '',
        cf_name: '',
        page: 1,
        page_size: 12,
        start_time: null
      }
      this.getFileList()
    },
    // 切换分页
    handleCurrentChange (val) {
      this.searchForm.page = val
      this.getFileList()
    },
    // 查看详情
    viewDesc (item) {
      this.drawerTitle = item.cf_name
      this.selectCfId = item.cf_id
      this.$store.commit('conference/set_drawerId', item.cf_id)
      this.$store.dispatch('conference/getHistoryCfItem', item.cf_id)
      this.$store.dispatch('conference/getCfRecord', item.cf_id)
      this.showCfDrawer = true
    },
    closeDrawer () {
      this.showCfDrawer = false
    }
  },
  created () {
    this.getFileList()
  }
}
</script>

<style scoped lang="scss">
.rightContent {
  height: calc(100% - 72px);
  padding: 24px 20px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    width: 12px;
  }

  &::-webkit-scrollbar-thumb {
    background-color: #d8dee9;
    border-radius: 2px;
  }

  label {
    .part {
      margin-left: 48px;
      &:first-child {
        margin-left: 0;
      }
    }
    span {
      font-size: 12px;
      margin-right: 12px;
    }

    input {
      width: 240px;
      height: 32px;
      border: 1px solid #d8dee9;
      border-radius: 2px;
      font-size: 12px;
      padding-left: 12px;
      vertical-align: middle;
    }

    .search,
    .reset {
      display: inline-block;
      width: 72px;
      height: 32px;
      line-height: 32px;
      vertical-align: middle;
      margin-left: 30px;
      font-size: 14px;
      margin-right: 0;
    }

    .reset {
      margin-left: 12px;
    }
  }

  table {
    margin-top: 24px;
    width: 100%;

    thead {
      th {
        font-weight: 500;
        font-size: 14px;
        text-align: left;
        background-color: #f9faff;
        height: 60px;
        border-bottom: 1px solid #ebedf3;

        &:first-child {
          padding-left: 20px;
          width: 400px;
        }

        &:nth-child(2) {
          width: 194px;
          min-width: 126px;
        }

        &:nth-child(3) {
          width: 194px;
        }
        &:nth-child(4) {
          width: 208px;
        }
        &:nth-child(5) {
          width: 284px;
        }
        &:last-child {
          min-width: 50px;
        }
      }
    }

    tbody {
      tr {
        td {
          height: 60px;
          font-size: 14px;
          text-align: left;
          color: #0D172C;
          line-height: 60px;
          border-bottom: 1px solid #ebedf3;
          &:first-child {
            padding-left: 20px;
          }
          .view {
            text-decoration: underline;
            color: #304eec;
          }
        }
      }
    }
  }

  }
  .el-pagination {
    margin-top: 24px;
    text-align: right;
  }
</style>
